# -*- coding: utf-8 -*-

from ..base_client import BaseClient
from common_sdk.system.sys_env import get_env


class FishBookClient(BaseClient):
    resource = "goods"

    def __init__(self):
        super().__init__()
        self.domain = get_env("TRADE_SERVICE_DOMAIN")

    def create_goods(self, builder):
        result = self.do_http_post_only_data(
            self.__generate_uri("create"),
            params=builder.params,
            headers=builder.headers
        )
        return result

    def get_goods(self, builder):
        result = self.do_http_post_only_data(
            self.__generate_uri("get"),
            params=builder.params,
            headers=builder.headers
        )
        return result

    def update_goods(self, builder):
        result = self.do_http_post_only_data(
            self.__generate_uri("update"),
            params=builder.params,
            headers=builder.headers
        )
        return result

    def list_goods(self, builder):
        result = self.do_http_post_only_data(
            self.__generate_uri("list"),
            params=builder.params,
            headers=builder.headers
        )
        return result

    def search_goods(self, builder):
        result = self.do_http_post_only_data(
            self.__generate_uri("search"),
            params=builder.params,
            headers=builder.headers
        )
        return result

    def delete_goods(self, builder):
        result = self.do_http_post_only_data(
            self.__generate_uri("delete"),
            params=builder.params,
            headers=builder.headers
        )
        return result

    def __generate_uri(self, operation):
        uri = f"{self.resource}/{operation}"
        return uri